#ifndef __SCREEN_H__
#define __SCREEN_H__

#include "bmp.h"
#include "graphics.h"
#include "ref.h"
#include "tool.h"
#include "word.h"

#define DEV_SCREEN "/dev/fb0"

extern uint16_t SCREEN_W;
extern uint16_t SCREEN_H;

typedef enum {
    LEFT_IN,
    RIGHT_IN,
    TOP_IN,
    BOTTOM_IN
} BMPShowMode;

bool Screen_Init();
void Screen_Free();

bool Screen_MapStart();
void Screen_MapEnd();

bool Screen_CanRW();
bool Screen_SetPaintStrokeWidth(uint8_t strokeWidth);
bool Screen_SetPaintColor(ColorInt color);

int32_t Screen_CalcIndex(uint16_t x, uint16_t y);

ColorInt Screen_ReadPixel(uint16_t x, uint16_t y);

void Screen_DrawPixel(uint16_t x, uint16_t y);
void Screen_DrawPixelWithColor(uint16_t x, uint16_t y, ColorInt color);
void Screen_DrawPixel2(Point *p);

void Screen_DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
void Screen_DrawLineWithColor(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, ColorInt color);
void Screen_DrawLine2(Line *line);

void Screen_DrawLines(uint16_t lines[][2], uint16_t len);

void Screen_DrawFilledCircle(uint16_t xCenter, uint16_t yCenter, uint16_t radius);
void Screen_DrawHollowCircleWithColor(uint16_t xCenter, uint16_t yCenter, uint16_t radius, ColorInt color);
void Screen_DrawFilledCircle(uint16_t xCenter, uint16_t yCenter, uint16_t radius);
void Screen_DrawFilledCircleWithColor(uint16_t xCenter, uint16_t yCenter, uint16_t radius, ColorInt color);

void Screen_DrawFilledRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
void Screen_DrawFilledRectWithColor(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ColorInt color);
void Screen_DrawRoundedRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius);
void Screen_DrawRoundedRectWithColor(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, ColorInt color);

void Screen_Fill();

void Screen_DrawChar(uint16_t w, uint16_t h, uint8_t word[][w / 8], uint16_t x, uint16_t y, ColorInt color);
void Screen_DrawNumber(int32_t number, uint16_t x, uint16_t y, ColorInt color);
void Screen_DrawTime(uint32_t seconds, uint16_t x, uint16_t y, ColorInt color, TimeMode mode);

void Screen_ShowBMP(BMP bmp, uint16_t x, uint16_t y);
void Screen_ShowBMPByFile(const char *fileName, uint16_t x, uint16_t y);
void Screen_ShowBMPWithMode(BMP bmp, BMPShowMode mode);
void Screen_ShowBMPWithModeByFile(const char *fileName, BMPShowMode mode);

void Screen_SaveRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ColorInt *savedData);

void Screen_RestoreRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ColorInt *savedData);

#endif /* __SCREEN_H__ */
